package com.ymatou.iapi.godmch.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.editmchBean;
import com.ymatou.iapi.godmch.parameter.getInviteDistributorPicBean;
import com.ymatou.iapi.godmch.parameter.registerByCodeBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.applyAgentCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.createSupplierCodeCall;
import com.ymatou.iapi.godmch.service.createagentCall;
import com.ymatou.iapi.godmch.service.getAgentPromotePicCall;
import com.ymatou.iapi.godmch.service.getInviteCpsPicCall;
import com.ymatou.iapi.godmch.service.getInviteDistributorPicCall;
import com.ymatou.iapi.godmch.service.registerByCodeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.business.service.shenqi.SqDistributorService;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.invite_code;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.model.godmch.buyer_invite_code;
import com.ymttest.database.model.godmch.buyer_invite_codeExample;
import com.ymttest.database.sqlwapper.godmch.agent_typeWapper;
import com.ymttest.database.sqlwapper.godmch.buyer_invite_codeWapper;
import com.ymttest.database.sqlwapper.godmch.country_infoWapper;
import com.ymttest.database.sqlwapper.godmch.invite_codeWapper;
import com.ymttest.database.sqlwapper.godmch.mch_infoWapper;
import com.ymttest.database.sqlwapper.godmch.mch_relationWapper;
import com.ymttest.utils.TestDataManager;
/**
*独立云邀请码注册
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_registerByCode{
	private static registerByCodeBean bean;
	private static registerByCodeCall call;
	
	agent_typeWapper agentTypeWapper=new agent_typeWapper();
	mch_infoWapper infoWapper=new mch_infoWapper();
	country_infoWapper country_infoWapper=new country_infoWapper();
	mch_relationWapper relationWapper=new mch_relationWapper();
	invite_codeWapper codeWapper=new invite_codeWapper();
	
	@BeforeClass
	public static void setUp() {	
		Logger.createResultFile("独立云邀请码注册");
	}

	@Before
	public void caseUp() {
		bean=new registerByCodeBean();
		call=new registerByCodeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_001() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册供货商");
		//供货商 无法成为分销小店
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			//agent_typeWapper
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", call.getRegMchId());
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			
			//mch_relation
			mch_relation relation=relationWapper.selectByPrimaryKey( bean.getMchId(),call.getRegMchId()).get(0);
			Logger.verifyEquals( agenttypeList.get(0).getAgentType(), relation.getAgentType(), "验证AgentType");
			Logger.verifyEquals(1, relation.getAgentModel(), "验证AgentModel");
			Logger.verifyEquals(0, relation.getState(), "验证state");
			Logger.verifyEquals(true, relation.getSamePlatform(), "验证SamePlatform");
			//mch_info
			List<Integer> mchIds=new ArrayList<Integer>();
			mchIds.add(call.getRegMchId());
			mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
			
			Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
			//纯代理
			Logger.verifyEquals(0, info.getAgent(), "验证数据库mch_info中的Agent=0");
			Logger.verifyEquals(1, info.getChannels(), "验证数据库mch_info中的Channels=0");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_002() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册代理2 - 自动继承（分销小店）");
		try {
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=createCall.getmchId();
			//Integer mchId=500021913;
		//	GodmchManageCallService.SetVip(mchId);
			//邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			createagentBean.setAgentMode(2);
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", mchId);
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);

			Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createCodeCall.getCode());
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			List<Integer> mchIds=new ArrayList<Integer>();
			mchIds.add(call.getRegMchId());
			mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
			Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
			//纯代理
			Logger.verifyEquals(1, info.getAgent(), "验证数据库mch_info中的Agent=0");
			Logger.verifyEquals(0, info.getChannels(), "验证数据库mch_info中的Channels=0");
			
			//查询代理类型
			 map=new HashMap();
			map.put("mchId", bean.getMchId());
			List<agent_type> list=agentTypeWapper.selectby(map);
			//mch_relation
			mch_relation relation=relationWapper.selectByPrimaryKey(call.getRegMchId(), bean.getMchId()).get(0);
			Logger.verifyEquals(list.get(2).getAgentType(), relation.getAgentType(), "验证AgentType");
			Logger.verifyEquals(2, relation.getAgentModel(), "验证AgentModel");
			Logger.verifyEquals(0, relation.getState(), "验证state");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_002_3() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册代理1 - 自主选货（分销代理");
		try {
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=createCall.getmchId();
			//Integer mchId=500021913;
		//	GodmchManageCallService.SetVip(mchId);
			//邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			createagentBean.setAgentMode(1);
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", mchId);
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);

			Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createCodeCall.getCode());
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			List<Integer> mchIds=new ArrayList<Integer>();
			mchIds.add(call.getRegMchId());
			mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
			Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
			//纯代理
			Logger.verifyEquals(1, info.getAgent(), "验证数据库mch_info中的Agent=0");
			Logger.verifyEquals(1, info.getChannels(), "验证数据库mch_info中的Channels=0");
			
			//查询代理类型
			 map=new HashMap();
			map.put("mchId", bean.getMchId());
			List<agent_type> list=agentTypeWapper.selectby(map);
			//mch_relation
			mch_relation relation=relationWapper.selectByPrimaryKey(call.getRegMchId(), bean.getMchId()).get(0);
			Logger.verifyEquals(list.get(2).getAgentType(), relation.getAgentType(), "验证AgentType");
			Logger.verifyEquals(1, relation.getAgentModel(), "验证AgentModel");
			Logger.verifyEquals(0, relation.getState(), "验证state");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_002_1() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册代理 -代理模式 1 - 自主选货（分销代理）");
		try {
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=createCall.getmchId();
			//GodmchManageCallService.SetVip(mchId);
			//邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			//createagentBean.setAgentMode(2);//
			createagentBean.setAgentMode(1);//
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", createCall.getmchId());
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);

			Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createCodeCall.getCode());
			call.setData(bean);
			call.callService();	
			
			//代理邀请码
			Integer agentId=call.getRegMchId();
			createagentBean createagentBean2=GodmchManageCallService.InitCreateAgentTypeBean(agentId);
			createagentBean2.setAgentMode(2);//
			createagentBean2.setRebateRate(new BigDecimal(30));
			createagentCall createagentCall2=GodmchManageCallService.CreateAgentTypeCall(createagentBean2);
			//代理code
			CreateCodeBean createCodeBean2=GodmchManageCallService.InitcreateCodeBeanForAgent(agentId, true);
			
			
			//查询类型
			agentTypewapper = new agent_typeWapper();
			map = new HashMap();
			map.put("mchId", mchId);
			agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(0).getAgentType());

			CreateCodeCall createCodeCall2=GodmchManageCallService.createCodeCall(createCodeBean2);
			Thread.sleep(5000);
			bean=GodmchManageCallService.initRegisterByCode(agentId, createCodeCall2.getCode());
	          bean.setMchId(mchId);
			// bean.setMchId(agentId);
	    	 bean.setAppKey("appsqSeller_" + mchId);
			// bean.setAppKey("appsqSeller_" + agentId);
	    	 bean.setInviteCode(createCodeCall2.getCode());//我记得之前 mchid没受控制。现在有控制,现在主要看InviteCode的类型确定 注册的用户类型
	    	 call.setData(bean);
			 call.callService();	

			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			List<Integer> mchIds=new ArrayList<Integer>();
			mchIds.add(call.getRegMchId());
			mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
			Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
			//纯代理
			Logger.verifyEquals(1, info.getAgent(), "验证数据库mch_info中的Agent=0");
			Logger.verifyEquals(0, info.getChannels(), "验证数据库mch_info中的Channels=0");
			
			//查询代理类型
			 map=new HashMap();
			//map.put("mchId", bean.getMchId());
			 map.put("mchId", agentId);
			List<agent_type> list=agentTypeWapper.selectby(map);
			//mch_relation
			mch_relation relation=relationWapper.selectByPrimaryKey(call.getRegMchId(),agentId).get(0);
			Logger.verifyEquals(list.get(0).getAgentType(), relation.getAgentType(), "验证AgentType");
			Logger.verifyEquals(2, relation.getAgentModel(), "验证AgentModel");
			Logger.verifyEquals(0, relation.getState(), "验证state");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_002_2() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册代理(独立商户-通过邀请码注册代理- 再发展小店代理)");
		try {
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=createCall.getmchId();
			GodmchManageCallService.SetVip(mchId);
			//主商户邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			//createagentBean.setAgentMode(2);//
			createagentBean.setAgentMode(1);//
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//主商户查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", createCall.getmchId());
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);

			Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createCodeCall.getCode());
			call.setData(bean);
			call.callService();	
			
			//代理1邀请码
			Integer agentId=call.getRegMchId();
			createagentBean createagentBean2=GodmchManageCallService.InitCreateAgentTypeBean(agentId);
			createagentBean2.setAgentMode(1);//
			createagentBean2.setRebateRate(new BigDecimal(30));
			createagentCall createagentCall2=GodmchManageCallService.CreateAgentTypeCall(createagentBean2);
			//代理code
			CreateCodeBean createCodeBean2=GodmchManageCallService.InitcreateCodeBeanForAgent(agentId, true);
			
			//查询类型
			agentTypewapper = new agent_typeWapper();
			map = new HashMap();
			map.put("mchId", mchId);
			agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(0).getAgentType());

			CreateCodeCall createCodeCall2=GodmchManageCallService.createCodeCall(createCodeBean2);
			Thread.sleep(5000);
			bean=GodmchManageCallService.initRegisterByCode(agentId, createCodeCall2.getCode());
	          bean.setMchId(mchId);
			 //bean.setMchId(agentId);
	    	 bean.setAppKey("appsqSeller_" + mchId);
	    	 bean.setInviteCode(createCodeCall2.getCode());
	    	 call.setData(bean);
			 call.callService();
			 Thread.sleep(5000);
			 //验证关系表1
			 map=new HashMap();
			 //map.put("mchId", bean.getMchId());
			 map.put("mchId", agentId);
			 List<agent_type> list=agentTypeWapper.selectby(map);
			 //mch_relation2
			 mch_relation relation=relationWapper.selectByPrimaryKey(call.getRegMchId(), agentId).get(0);
			 Logger.verifyEquals(list.get(0).getAgentType(), relation.getAgentType(), "验证AgentType");
			 Logger.verifyEquals(1, relation.getAgentModel(), "验证AgentModel");
			 Logger.verifyEquals(0, relation.getState(), "验证state");
			
			
			 
			 //代理2邀请码
			 Integer agentId2=call.getRegMchId();
			 createagentBean2=GodmchManageCallService.InitCreateAgentTypeBean(agentId2);
			 createagentBean2.setAgentMode(2);//2 - 自动继承（分销小店）
			 createagentBean2.setRebateRate(new BigDecimal(40));
			 createagentCall2=GodmchManageCallService.CreateAgentTypeCall(createagentBean2);
			 //代理code
			 createCodeBean2=GodmchManageCallService.InitcreateCodeBeanForAgent(agentId2, true);
		 
			 //查询类型
			 agentTypewapper = new agent_typeWapper();
			 map = new HashMap();
			 map.put("mchId", agentId2);
			 agenttypeList = agentTypewapper.selectby(map);
			 
			 
			 createCodeBean2.setRoleType(agenttypeList.get(0).getAgentType());
			 createCodeCall2=GodmchManageCallService.createCodeCall(createCodeBean2);
			 
			 Thread.sleep(5000);
			 bean=GodmchManageCallService.initRegisterByCode(mchId, createCodeCall2.getCode());
	         // bean.setMchId(mchId);
			 bean.setMchId(mchId);
	    	 bean.setAppKey("appsqSeller_" + mchId);
	    	 bean.setInviteCode(createCodeCall2.getCode());
	    	 call.setData(bean);
			 call.callService();
				
				
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			List<Integer> mchIds=new ArrayList<Integer>();
			mchIds.add(call.getRegMchId());
			mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
			Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
			//纯代理
			Logger.verifyEquals(1, info.getAgent(), "验证数据库mch_info中的Agent=0");
			Logger.verifyEquals(0, info.getChannels(), "验证数据库mch_info中的Channels=0");
			
			//查询代理类型
			 map=new HashMap();
			//map.put("mchId", bean.getMchId());
			map.put("mchId", agentId2);
			list=agentTypeWapper.selectby(map);
			//mch_relation2
			 relation=relationWapper.selectByPrimaryKey(call.getRegMchId(), agentId2).get(0);
			Logger.verifyEquals(list.get(0).getAgentType(), relation.getAgentType(), "验证AgentType");
			Logger.verifyEquals(2, relation.getAgentModel(), "验证AgentModel");
			Logger.verifyEquals(0, relation.getState(), "验证state");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_003() {
		Logger.start(true,"独立云邀请码注册-验证供货商-商户所属国家CHN");
		try {
			
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("CHN");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();				
			
//			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");
//			Logger.verifyEquals("供货商不支持中国大陆身份注册", call.getMessage(), "验证Message");

			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_003_1() {
		Logger.start(true,"独立云邀请码注册-验证代理_商户所属国家CHN");
		try {
			
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=createCall.getmchId();
			//邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			createagentBean.setAgentMode(2);//
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", createCall.getmchId());
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);

			Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("CHN");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createCodeCall.getCode());
			call.setData(bean);
			call.callService();				
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			List<Integer> mchIds=new ArrayList<Integer>();
			mchIds.add(call.getRegMchId());
			mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
			Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
			//纯代理
			Logger.verifyEquals(1, info.getAgent(), "验证数据库mch_info中的Agent=0");
			Logger.verifyEquals(0, info.getChannels(), "验证数据库mch_info中的Channels=0");
			
			//查询代理类型
			 map=new HashMap();
			map.put("mchId", bean.getMchId());
			List<agent_type> list=agentTypeWapper.selectby(map);
			//mch_relation
			mch_relation relation=relationWapper.selectByPrimaryKey(call.getRegMchId(), bean.getMchId()).get(0);
			Logger.verifyEquals(list.get(2).getAgentType(), relation.getAgentType(), "验证AgentType");
			Logger.verifyEquals(2, relation.getAgentModel(), "验证AgentModel");
			Logger.verifyEquals(0, relation.getState(), "验证state");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_004() {
		Logger.start(true,"独立云邀请码注册-验证独立云主商户id与邀请码不一致-目前case有问题,开发整理逻辑");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            
    		createIndepMchBean createIndepMchBean2=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall2=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean2);
            
            Integer mchId=createIndepMchCall.getmchId();
            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(createIndepMchCall2.getmchId());
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();		
			org.junit.Assert.fail();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_registerByCode_005() {
		Logger.start(true,"独立云邀请码注册-验证mchId不是独立云主商户-(研发未对mchId做校验处理，主要是通过邀请码code来确认上级关系)");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Integer plat=GodmchManageCallService.CreateSellerMch();
            
            Thread.sleep(5000);
            bean.setMchId(plat);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_006() {
		Logger.start(true,"独立云邀请码注册-验证商户Id为空");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
           // bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_007() {
		Logger.start(true,"独立云邀请码注册-验证mobile为空");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
         //   bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_008() {
		Logger.start(true,"独立云邀请码注册-验证password为空");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
          //  bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_008_1() {
		Logger.start(true,"独立云邀请码注册-验证password格式不对(密码格式错误,6-9位数字和英文字母组合)");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

            createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc");
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_009() {
		Logger.start(true,"独立云邀请码注册-验证inviteCode为空");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();

           // createSupplierCodeCall createSupplierCodeCall=GodmchManageCallService.createSupplierCode(mchId);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc");
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		//bean.setInviteCode(createSupplierCodeCall.getCode());
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_010() {
		Logger.start(true,"独立云邀请码注册-验证平台云的邀请码用于独立云-失败");
		//供货商 无法成为分销小店
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            
            int mchId2 = GodmchManageCallService.CreateSellerMch();
        	//邀请码
			CreateCodeBean createbean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId2);
			CreateCodeCall createcall=GodmchManageCallService.createCodeCall(createbean);
            
            Thread.sleep(5000);
            bean.setMchId(mchId);
            bean.setCountry("USA");
            
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    	//	bean.setInviteCode(createcall.getCode());
    		bean.setInviteCode(createcall.getCode());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");
			//Logger.verifyEquals("邀请码不存在", call.getMessage(), "验证Message");
			//Logger.verifyEquals("独立云平台不支持公有云邀请码注册", call.getMessage(), "验证Message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_011() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册代理(独立商户-通过邀请码注册代理- 再发展小店代理)");
		try {
               ///////////////主商户////////
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=createCall.getmchId();
			GodmchManageCallService.SetVip(mchId);
			//邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			// 创建代理类型
			createagentBean createagentBean = GodmchManageCallService.InitCreateAgentTypeBean(mchId);
			//createagentBean.setAgentMode(2);//
			createagentBean.setAgentMode(1);//
			createagentCall createagentcall = GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			//查询类型
			agent_typeWapper agentTypewapper = new agent_typeWapper();
			Map<String, Object> map = new HashMap();
			map.put("mchId", createCall.getmchId());
			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(2).getAgentType());
			
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);

			Thread.sleep(5000);
			bean=GodmchManageCallService.initRegisterByCode(mchId, createCodeCall.getCode());
			call=GodmchManageCallService.registerByCodeCall(bean);
			
			//代理邀请码
			Integer agentId=call.getRegMchId();
			createagentBean createagentBean2=GodmchManageCallService.InitCreateAgentTypeBean(agentId);
			createagentBean2.setAgentMode(2);//
			createagentBean2.setRebateRate(new BigDecimal(30));
			createagentCall createagentCall2=GodmchManageCallService.CreateAgentTypeCall(createagentBean2);
			//代理code
			CreateCodeBean createCodeBean2=GodmchManageCallService.InitcreateCodeBeanForAgent(agentId, true);
			
			
			//查询类型
			 agentTypewapper = new agent_typeWapper();
			 map = new HashMap();
			map.put("mchId", mchId);
			agenttypeList = agentTypewapper.selectby(map);
			createCodeBean.setRoleType(agenttypeList.get(0).getAgentType());

			CreateCodeCall createCodeCall2=GodmchManageCallService.createCodeCall(createCodeBean2);
			Thread.sleep(5000);
			bean=GodmchManageCallService.initRegisterByCode(agentId, createCodeCall2.getCode());
	         // bean.setMchId(mchId);
			bean.setMchId(agentId);
	    	bean.setAppKey("appsqSeller_" + mchId);
	    	bean.setInviteCode(createCodeCall2.getCode());
	    	call.setData(bean);
			call.callService();	
			
		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_012() {
		Logger.start(true,"独立云邀请码注册-验证商户是独立商户注册分销员(数据库不落数据)");
		try {
			
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            Logger.comment("###########独立商户："+mchId);
            
            Logger.comment("###########独立商户审核：");
            SqDistributorService.createAutoAuditDistributor((long)mchId);
            
        	//独立商户邀请分享图
            getInviteDistributorPicBean getInviteDistributorPicBean=GodmchManageCallService.initGetInviteDistributorPicBean(mchId);
            getInviteDistributorPicCall getInviteDistributorPicCall=GodmchManageCallService.getInviteDistributorPicBeanCall(getInviteDistributorPicBean);
            Logger.comment("###########独立商户图片：");
            
            Thread.sleep(5000);
            bean.setMchId(mchId); //这个字段在分销员中没有作用
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(getInviteDistributorPicCall.getResult().get("inviteCode").getAsString());
			call.setData(bean);
			call.callService();	
	        Logger.comment("###########独立商户分销员：");	
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(true, call.getRegMchId()>0, "验证regMchId");
			Logger.verifyEquals(4, call.getRegType(), "验证RegType");
			//验证数据库
			invite_code invite_code=codeWapper.selectByCode(bean.getInviteCode());
			Logger.verifyEquals(call.getRegType(), invite_code.getCodeRole(), "验证数据库中的InviteCode");
			Logger.verifyEquals(bean.getInviteCode(), invite_code.getInviteCode(), "验证数据库中的InviteCode");
			Logger.verifyEquals(mchId, invite_code.getMchId(), "验证数据库中的MchId");
			Logger.verifyEquals(mchId, invite_code.getShopId(), "验证数据库中的ShopId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_registerByCode_013() {
		Logger.start(true,"独立云邀请码注册-验证商户是分销员发展分销员");
		//思路1：创建独立商户  2：独立商户自动审核分销员 3：独立商户分享图片，得到分销员code 4：分销员通过独立商户分享的二维码图片注册分销员1
		//5:分销员1 分享二维码图片 得到分销员code 6：新分销员通过code注册分销员2
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
            Integer mchId=createIndepMchCall.getmchId();
            Logger.comment("###########独立商户："+mchId);
            SqDistributorService.createAutoAuditDistributor((long)mchId);
            
        	//独立商户邀请分享图
            Logger.comment("###########独立商户图片：");
            getInviteDistributorPicBean getInviteDistributorPicBean=GodmchManageCallService.initGetInviteDistributorPicBean(mchId);
            getInviteDistributorPicCall getInviteDistributorPicCall=GodmchManageCallService.getInviteDistributorPicBeanCall(getInviteDistributorPicBean);
        
            Logger.comment("###########独立商户审核：");
            Thread.sleep(5000);
            bean.setMchId(mchId); //这个字段在分销员中没有作用
            bean.setCountry("USA");
            bean.setMobile(TestDataManager.getPhoneNum());
            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
        	bean.setAppSource(60);// 代购神器买家端小程序
    		bean.setTerminalSource(0);// 其他 default
    		bean.setAppKey("appsqSeller_" + mchId);
    		bean.setInviteCode(getInviteDistributorPicCall.getResult().get("inviteCode").getAsString());
			call.setData(bean);
			call.callService();	
			Integer reMchId1=call.getRegMchId();
	        Logger.comment("###########独立商户分销员：");
			
	        //需要分销员审核
	        SqDistributorService.updateDistributorInfo((long)mchId, (long)call.getRegMchId());
			//分销员1邀请分享图
	        getInviteDistributorPicBean getInviteDistributorPicBean2=GodmchManageCallService.initGetInviteDistributorPicBean(call.getRegMchId());
	        getInviteDistributorPicCall getInviteDistributorPicCall2=GodmchManageCallService.getInviteDistributorPicBeanCall(getInviteDistributorPicBean2);

	        bean.setMobile(TestDataManager.getPhoneNum());
	        bean.setInviteCode(getInviteDistributorPicCall2.getResult().get("inviteCode").getAsString());
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(true, call.getRegMchId()>0, "验证regMchId");
			Logger.verifyEquals(4, call.getRegType(), "验证RegType");
			//验证数据库
			//分销员1
			invite_code invite_code=codeWapper.selectByCode(getInviteDistributorPicCall.getResult().get("inviteCode").getAsString());
			Logger.verifyEquals(mchId, invite_code.getMchId(), "验证分销员1 数据库中的MchId ");
			Logger.verifyEquals(mchId, invite_code.getShopId(), "验证分销员1 数据库中的ShopId");
			//分销员2
			invite_code=codeWapper.selectByCode(bean.getInviteCode());
			Logger.verifyEquals(call.getRegType(), invite_code.getCodeRole(), "验证数据库中的InviteCode");
			Logger.verifyEquals(bean.getInviteCode(), invite_code.getInviteCode(), "验证数据库中的InviteCode");
			Logger.verifyEquals(reMchId1, invite_code.getMchId(), "验证分销员2 数据库中的MchId");
			Logger.verifyEquals(mchId, invite_code.getShopId(), "验证分销员2 数据库中的ShopId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	   @Test
		@Category({P1.class})
		@TestCase
		public void Tc_registerByCode_014() {
			Logger.start(true,"独立云邀请码注册-验证商户是渠道商-新增20200731");
			try {
                //mch_info中的PlatformMchId 对应独立商户平台Id
				createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
	            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
	            Integer mchId=createIndepMchCall.getmchId();           
	            String inviteCode= GodmchManageCallService.getChannelPic(mchId).getInviteCode();

	            bean.setMchId(mchId);
	            bean.setCountry("USA");
	            bean.setMobile(TestDataManager.getPhoneNum());
	            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
	        	bean.setAppSource(60);// 代购神器买家端小程序
	    		bean.setTerminalSource(0);// 其他 default
	    		bean.setAppKey("appsqSeller_" + mchId);
	    		bean.setInviteCode(inviteCode);
				call.setData(bean);
				call.callService();			
				
				Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
				Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
				//agent_typeWapper
				agent_typeWapper agentTypewapper = new agent_typeWapper();
				Map<String, Object> map = new HashMap();
				map.put("mchId", call.getRegMchId());
				List<agent_type> agenttypeList = agentTypewapper.selectby(map);
				//mch_info
				List<Integer> mchIds=new ArrayList<Integer>();
				mchIds.add(call.getRegMchId());
				mch_info  info=infoWapper.selectbyMchIds(mchIds).get(0);
				
				Logger.verifyEquals(0, info.getState(), "验证数据库mch_info中的State=0审核通过");
				//纯代理
				Logger.verifyEquals(0, info.getAgent(), "验证数据库mch_info中的Agent=0");
				Logger.verifyEquals(1, info.getChannels(), "验证数据库mch_info中的Channels=1");
				Logger.verifyEquals(mchId, info.getPlatformMchId(), "验证数据库mch_info中的PlatformMchId 对应独立商户平台Id");
				
			} catch (Exception e) {
				Logger.fail(e);
			}
		}
	
	
	
	   @Test
		@Category({P1.class})
		@TestCase
		public void Tc_registerByCode_015() {
			Logger.start(true,"独立云邀请码注册-验证商户是分销机构-新增20200807(数据库不落数据)");
			try {
//               //mch_info中的PlatformMchId 对应独立商户平台Id
//				createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
//	            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
//	            Integer mchId=createIndepMchCall.getmchId();
				
	            Integer mchId=501336050;
	            String inviteCode= GodmchManageCallService.getInviteDistributorOrganizationPic(mchId).getInviteCode();

	            bean.setMchId(mchId);
	            bean.setCountry("USA");
	            bean.setMobile(TestDataManager.getPhoneNum());
	            bean.setPassword("testanc"+TestDataManager.getRandomNum(2));
	        	bean.setAppSource(60);// 代购神器买家端小程序
	    		bean.setTerminalSource(0);// 其他 default
	    		bean.setAppKey("appsqSeller_" + mchId);
	    		bean.setInviteCode(inviteCode);
				call.setData(bean);
				call.callService();			
				
				Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
				Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
				Logger.verifyEquals(true, call.getRegMchId()>0, "验证regMchId");
				Logger.verifyEquals(6, call.getRegType(), "验证RegType");
				//验证数据库
				invite_code invite_code=codeWapper.selectByCode(bean.getInviteCode());
				Logger.verifyEquals(call.getRegType(), invite_code.getCodeRole(), "验证数据库中的InviteCode");
				Logger.verifyEquals(bean.getInviteCode(), invite_code.getInviteCode(), "验证数据库中的InviteCode");
				Logger.verifyEquals(mchId, invite_code.getMchId(), "验证数据库中的MchId");
				Logger.verifyEquals(mchId, invite_code.getShopId(), "验证数据库中的ShopId");
				//buyer_invite_code
				buyer_invite_codeWapper buyer_invite_codeWapper=new buyer_invite_codeWapper();
				buyer_invite_codeExample example=new buyer_invite_codeExample();
				example.createCriteria().andUserIdEqualTo(call.getRegMchId());
				buyer_invite_code buyer_invite_code=buyer_invite_codeWapper.selectByExample(example).get(0);
				Logger.verifyEquals(3, buyer_invite_code.getUserType(), "验证数据库中的UserType=3");
				Logger.verifyEquals(true, buyer_invite_code.getInvitePicUrl().length()>0, "验证数据库中的InvitePicUrl");
				Logger.verifyEquals(true, buyer_invite_code.getInviteCode().length()>0, "验证数据库中的InviteCode");
				
			} catch (Exception e) {
				Logger.fail(e);
			}
		}
	
	    @Test
		@Category({P1.class})
		@TestCase
		public void Tc_registerByCode_016() {
			Logger.start(true,"独立云邀请码注册-验证代理裂变-独立商户注册代理-代理再邀请代理");
			try {

				Integer mchId=501371929;
				//获取主商户agentType
				agent_typeWapper agentTypewapper = new agent_typeWapper();
				Map<String, Object> map = new HashMap();
				map.put("mchId", mchId);
				List<agent_type> agenttypeList = agentTypewapper.selectby(map);
				
				//申请 审核代理1
				applyAgentCall applyAgent =GodmchManageCallService.applyAndapproveAgent(mchId);
				editmchBean editmchBean=GodmchManageCallService.IniteditmachBean(applyAgent.getAgentId());
	            GodmchManageCallService.editmachCall(editmchBean);
				
				getAgentPromotePicCall getAgentPromotePicCall=GodmchManageCallService.getAgentPromotePic(applyAgent.getAgentId());
				Thread.sleep(5000);
				bean=GodmchManageCallService.initRegisterByCode(mchId, getAgentPromotePicCall.getInviteCode());
				call=GodmchManageCallService.registerByCodeCall(bean);
				Integer agentId2=call.getRegMchId();
				Logger.comment("################ agentId2:"+agentId2);
				//验证1
				//mch_relation
				mch_relation relation=relationWapper.selectByPrimaryKey(call.getRegMchId(), bean.getMchId()).get(0);
				Logger.verifyEquals( agenttypeList.get(0).getAgentType(), relation.getAgentType(), "验证AgentType");
				Logger.verifyEquals(1, relation.getAgentModel(), "验证AgentModel");
				Logger.verifyEquals(0, relation.getState(), "验证state");
				Logger.verifyEquals(true, relation.getSamePlatform(), "验证SamePlatform");
				Logger.verifyEquals(applyAgent.getAgentId(), relation.getInviterId(), "验证inviterId");
				
				//申请 审核代理2
				editmchBean=GodmchManageCallService.IniteditmachBean(call.getRegMchId());
	            GodmchManageCallService.editmachCall(editmchBean);
                getAgentPromotePicCall=GodmchManageCallService.getAgentPromotePic(call.getRegMchId());
			    Thread.sleep(5000);
			    bean=GodmchManageCallService.initRegisterByCode(mchId, getAgentPromotePicCall.getInviteCode());
			    call=GodmchManageCallService.registerByCodeCall(bean);
			    
				//验证2
				relation=relationWapper.selectByPrimaryKey( call.getRegMchId(), bean.getMchId()).get(0);
				Logger.verifyEquals( agenttypeList.get(0).getAgentType(), relation.getAgentType(), "验证AgentType");
				Logger.verifyEquals(1, relation.getAgentModel(), "验证AgentModel");
				Logger.verifyEquals(0, relation.getState(), "验证state");
				Logger.verifyEquals(true, relation.getSamePlatform(), "验证SamePlatform");
				Logger.verifyEquals(agentId2, relation.getInviterId(), "验证inviterId");
				
			} catch (Exception e) {
				Logger.fail(e);
			}
		}
	    
	    
	    
	    @Test
		@Category({P1.class})
		@TestCase
		public void Tc_registerByCode_017() {
			Logger.start(true,"独立云注册-邀请CPS分享图片-CPS注册");
			try {
				
//				createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
//	            createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
	           // Integer mchId=createIndepMchCall.getmchId();
	            Integer mchId=501571125;

	            getInviteCpsPicCall getInviteCpsPicCall=GodmchManageCallService.getInviteCpsPic(mchId);
				
				bean.setCountry("AUS");
				bean.setMobile(TestDataManager.getPhoneNum());
				bean.setPassword("www123");
				bean.setAppSource(60);// 代购神器买家端小程序
				bean.setTerminalSource(0);// 其他 default
				bean.setAppKey("appsqseller_"+mchId);
				bean.setMchId(mchId);
				bean.setInviteCode(getInviteCpsPicCall.getInviteCode());
				call.setData(bean);
				call.callService();			
				
				Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
				Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
				Logger.verifyEquals(true, call.getRegMchId()>0, "验证regMchId");
				Logger.verifyEquals(7, call.getRegType(), "验证RegType");			
				
			} catch (Exception e) {
				Logger.fail(e);
			}
		}
}